#pragma once

#include "Animation.h"
#include "Frame.h"
#include "AnimationTimeStamp.h"
#include "GameObject.h"

#include <map>
using namespace std;

class AnimationSystem
{
public:
	//SINGLETON:
	// static accessor to get the singleton object
	static AnimationSystem* GetInstance();
	static void DeleteInstance();

	
	void Initialize();

	void Update(AnimationTimeStamp& ATS, float elapsedTime, GameObject* eventSender);
	void Render(SGD::Point renderPosition, AnimationTimeStamp& ATS);

	void StartLooping(AnimationTimeStamp& ATS);
	void StartPlaying(AnimationTimeStamp& ATS);

	void StopAnimation(AnimationTimeStamp& ATS);

	bool GetAnimationInfoFromFile(char* theFile);

	void AddAnimation(string name, vector<Frame> anim, SGD::HTexture img);

	void UnloadTexture();

	SGD::Rectangle GetCollisionRectangle(AnimationTimeStamp& ATS);


	map<string, Animation>& GetLoaded() { return loaded; }
	void SetLoaded(map<string, Animation> x) { loaded = x; }

	bool Contains(string animation);
private:
	static AnimationSystem* s_pInstance;

	AnimationSystem() = default;
	~AnimationSystem() = default;
	AnimationSystem(const AnimationSystem&) = delete;
	AnimationSystem& operator= (const AnimationSystem&) = delete;

	map<string, Animation> loaded;
	
	vector<SGD::HTexture> images;
	vector<string> loadedFiles;

	bool turnedAround = false;
	bool facingleft = false;
};

